<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Ajax extends CI_Controller {
	function __construct(){
		parent::__construct();
		$this->load->model('Login_model');
	}

	public function login(){
	
		log_message(ETS_INFO, '### C:ajax->login');
		$post = $this->input->post(NULL,TRUE);
		$username = trim($post[AJAX_PARAM_USER_NAME]);
		$userpass = trim($post[AJAX_PARAM_USER_PWD]);
		$role = trim($post[AJAX_PARAM_USER_ROLE]);
		log_message(ETS_INFO, '### option:'.$post[AJAX_PARAM_OPTION]);
		log_message(ETS_INFO, '### username:'.$post[AJAX_PARAM_USER_NAME]);
		log_message(ETS_INFO, '### pwd:'.$post[AJAX_PARAM_USER_PWD]);
		log_message(ETS_INFO, '### role:'.$post[AJAX_PARAM_USER_ROLE]);
		if(AJAX_PARAM_OPTION_AJAX == $post[AJAX_PARAM_OPTION]){
			if($this->Login_model->login($username,$userpass, $role)){
				log_message(ETS_INFO, '### return ok');
				echo 'ok';
				exit;
			}
		}
		log_message(ETS_INFO, '### error');
		echo 'error';
		exit;
	}
}